﻿using Castle.DynamicProxy;
using CNKI.TPI.Web.Base;
using CNKI.TPI.Web.Sys.IBLL;
using CNKI.TPI.Web.Sys.IDAO;
using CNKI.TPI.Web.Sys.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CNKI.TPI.Web.Sys.BLL
{
    public enum ShowType
    {
        /// <summary>
        /// 图片新闻栏目
        /// </summary>
        PicNews = 1,
        /// <summary>
        /// 文章新闻栏目
        /// </summary>
        ArticleNews = 2,
        /// <summary>
        /// 首页推荐栏目
        /// </summary>
        ArticleRecommend = 3,
        /// <summary>
        /// 站点公告栏目
        /// </summary>
        Notice = 4,
        /// <summary>
        /// 图片推荐栏目
        /// </summary>
        PicRecommend = 5,
    };
    public enum TemplateType
    {
        /// <summary>
        /// 文字模板
        /// </summary>
        Article = 1,
        /// <summary>
        /// 图片模板
        /// </summary>
        Pic = 2,
    };
    public class HomeService : BaseService, IHomeService
    {
        private IHomeDAO homeDao = null;

        public HomeService(IHomeDAO homeDao)
        {
            this.homeDao = this.generator.CreateInterfaceProxyWithTarget<IHomeDAO>(homeDao, new IInterceptor[] { new LogInterceptor() });
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IList<SYS_CMS_NEWS_NEWSCONTENTCONFIG> GetHomepageConfig()
        {
            IList<SYS_CMS_NEWS_NEWSCONTENTCONFIG> result = homeDao.GetHomepageConfig();
            return result.Where(c => c.IsPub == 1).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public IList<SYS_CMS_NEWS_NEWSCONTENTCONFIG> GetHomepageConfig(int type)
        {
            IList<SYS_CMS_NEWS_NEWSCONTENTCONFIG> result = homeDao.GetHomepageConfig();
            return result.Where(c => c.IsPub == 1 && c.ShowType == type).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IList<SYS_CMS_NEWS_JUMPTEMPLATE> GetHomepageJumpConfig()
        {
            IList<SYS_CMS_NEWS_JUMPTEMPLATE> result = homeDao.GetHomepageJumpConfig();
            return result.Where(c => c.IsPub == "1").ToList();
        }
    }
}
